package com.lagou.client;

import com.lagou.config.HostConfig;
import com.lagou.zookeeper.ZkClientFactory;
import org.apache.curator.framework.CuratorFramework;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author
 */
@Component
public class ZkClientUtil implements InitializingBean {

    @Autowired
    private HostConfig hostConfig;

    private static String path;

    private final CuratorFramework zkClient = ZkClientFactory.getZkClient();

    public CuratorFramework getZkClient() {
        return zkClient;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        path = ZkClientFactory.COST_TIME + "/" + hostConfig.getAddr() + "/time";
    }

    public String getPath() {
        return path;
    }
}
